#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGridLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setupGridLayout();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::setupGridLayout()
{
    QWidget *centeralWidget = new QWidget(this);
    QGridLayout* grid = new QGridLayout(centeralWidget);
    grid->setSpacing(5);
    grid->setContentsMargins(10, 10, 10, 10);

    // 创建4x4网格
    for (int row = 0; row < 2; ++row) {
         for (int col = 0; col < 2; ++col) {
              QWidget *video = new QWidget(this);

              // 设置单元格样式
                              video->setStyleSheet(
                                  "QWidget {"
                                  "  border: 2px solid #666;"    // 灰色边框
                                  "  background: #FFF;"          // 白色背景
                                  "  border-radius: 4px;"        // 圆角（可选）
                                  "}"
                              );

                              // 设置最小尺寸保证显示效果
                              video->setMinimumSize(640, 360);

              grid->addWidget(video, row, col);
          }
   }

    setCentralWidget(centeralWidget);
    resize(1280, 720);
}

